﻿using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;

using System.Collections.Generic;
using OpenSda.Agilcont.Common.Business.Contracts;
using OpenSda.Agilcont.Common.Data.Entities;
using OpenSda.Agilcont.Common.Data.Contracts;
using OpenSda.Agilcont.Common.Business.Exceptions;
namespace OpenSda.Agilcont.Common.Business.SfContexts.NmTest
{
    [TestFixture]
    public class DataAccessAgenciaConfigBusinessTest : AbstractBaseDataTests
    {
        private IDataAccessAgenciaConfigBusiness target;
        public IDataAccessAgenciaConfigBusiness DataAccessAgenciaConfigBusiness { set { target = value; } }
        private IModuleAccessData moduleAccessData;
        public IModuleAccessData ModuleAccessData { set { moduleAccessData = value; } }

        [Test]
        [ExpectedException(typeof(DataAccessAgenciaConfigCannotBeNullException))]
        public void SaveWhenDataAccessAgenciaConfigIsNullTest()
        {
            target.Save(null);
        }

        [Test]
        public void SaveTest()
        {
            DataAccessAgenciaConfig dataAccessAgenciaConfig = this.Save();
            Assert.IsNotNull(dataAccessAgenciaConfig.Identity);
        }
        private DataAccessAgenciaConfig Save()
        {
            ModuleAccess mc = moduleAccessData.GetAll()[0];
            return target.Save(new DataAccessAgenciaConfig()
            {
                Role = "ajsbhdjgh",
                ModuleAccessRef = mc

            });
        }
        [Test]
        public void GetByIdTest()
        {
            DataAccessAgenciaConfig dataAccessAgenciaConfig = this.Save();
            //target.Delete(DataAccessAgenciaConfig);
            DataAccessAgenciaConfig u = target.GetByid(user.Identity);
            Assert.IsNotNull(u.Identity);
        }

    }
}
